<template>
    <el-dialog :title="title" :visible.sync="visible" width="50%" append-to-body>
        <div class="Information">
            <el-row>
                <el-form :model="form" :inline="true">
                    <el-col :span="5">
                        <el-form-item label="姓名:">{{ form.studentName }} </el-form-item>
                    </el-col>
                    <el-col :span="11">
                        <el-form-item>{{ form.dm }} </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="申请时间:">{{ form.applyTime }} </el-form-item>
                    </el-col>

                    <el-col :span="24">
                        <el-form-item label="申请说明:">{{ form.applyReason }} </el-form-item>
                    </el-col>
                </el-form>
            </el-row>
            <div class="titleStatus">
                {{ form.apprStatus }}
            </div>
        </div>
        <div class="Information">
            <el-row>
                <el-form :model="form" :inline="true">
                    <el-col :span="6">
                        <el-form-item label="用工部门:">{{ form.wspDeptPost.deptName }} </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="岗位名称:">{{ form.wspDeptPost.postName }} </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="用共时长:">{{ form.wspDeptPost.workHours }}小时 </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="岗位薪酬:">{{ form.wspDeptPost.postComp }}元/时</el-form-item>
                    </el-col>

                    <el-col :span="24">
                        <el-form-item label="岗位需求人数:">{{ form.wspDeptPost.postReqCount }} </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="岗位描述:">{{ form.wspDeptPost.postDesc }} </el-form-item>
                    </el-col>
                </el-form>
            </el-row>
        </div>
        <el-row>
            <el-form ref="form" :model="form" :rules="rules" label-width="90px" v-if="form.apprStatus == '待审核' ? true : false">
                <el-row>
                    <el-col :span="24">
                        <el-form-item label="审核结果:" prop="apprType">
                            <el-radio-group v-model="form.apprType">
                                <el-radio label="Y">通过</el-radio>
                                <el-radio label="N">不通过</el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="不通过原因:" prop="apprCause" v-if="form.apprType == 'Y' ? false : true">
                            <el-input v-model="form.apprCause" placeholder="请输入审核失败原因"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </el-row>
        <div slot="footer" class="dialog-footer" v-if="form.apprStatus == '待审核' ? true : false">
            <el-button type="primary" @click="submitForm">确 定</el-button>
            <el-button @click="visible = false">取 消</el-button>
        </div>
    </el-dialog>
</template>

<script>
import { getDicts } from "@/api/system/dict/type";
import { postempAppr } from '@/api/worStudy/postManagement'
export default {
    name: 'organizationAddDlg',
    props: {
        treeData: {
            type: Array,
            default: []
        }
    },
    data() {
        return {
            title: '',
            visible: false,
            formdata: {
                gradeName: 10

            },
            rules: {
                apprType: [
                    { required: true, message: "请选择审核结果", trigger: "change" }
                ],
                apprCause: [
                    { required: true, message: "请输入不通过原因", trigger: "blur" }
                ],
            },
            type: 'add',
            form: {}
        }
    },
    methods: {
        open(data, type) {
            console.log(data, '详情')
            this.type = type
            this.title = '详情'
            this.form = data
            this.visible = true
            getDicts("wsp_appr_status").then(res => {
            res.data.forEach(e => {
                   if(this.form.apprStatus == e.dictValue) {
                    this.form.apprStatus = e.dictLabel
                   }
            })
            });
        },
        submitForm() {
            this.$refs["form"].validate(valid => {
                console.log(valid)
                postempAppr(this.form).then(response => {
                    this.$modal.msgSuccess("审批成功");
                    this.visible = false;
                    this.$emit('updateList');
                });
            });
        }
    }

}
</script>

<style lang="scss" scoped>
.Information {
    background-color: #EFEFEF;
    padding: 1% 2% 0 2%;
    margin-bottom: 2%;
}

.titleStatus {
    width: 100px;
    height: 100px;
    border: 5px solid #4095E5;
    border-radius: 50%;
    position: absolute;
    top: 112px;
    right: 35px;
    line-height: 100px;
    text-align: center;
    transform: rotate(-35deg);
}
</style>